//
//  TLRechargeCollectionViewCell.m
//  WXReader
//
//  Created by huaya on 2025/1/16.
//  Copyright © 2025 Andrew. All rights reserved.
//

#import "TLRechargeCollectionViewCell.h"
@interface TLRechargeCollectionViewCell()
@property (weak, nonatomic) IBOutlet UIView *lxView;

@property (weak, nonatomic) IBOutlet UILabel *lxLab;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *oneLab;

@property (weak, nonatomic) IBOutlet UILabel *twoLab;
@property (weak, nonatomic) IBOutlet UILabel *threeLab;


@property (nonatomic, assign) bool isSelected;
@end

@implementation TLRechargeCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    _isSelected = YES;
    
    self.bgView.layer.cornerRadius = 6;
    self.bgView.layer.borderWidth = 1;
    self.bgView.layer.borderColor = [UIColor colorWithHexString:@"#C8C8C8"].CGColor;
    [self.bgView setBackgroundColor:[UIColor whiteColor]];
    
//    UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(checkAction)];
//    
//    self.bgView.userInteractionEnabled = YES;
//    [self.bgView addGestureRecognizer:tapG];
    
//    [self checkAction];
}
//- (void)checkAction{
//    _isSelected = !_isSelected;
//    
//    if (_isSelected) {
//        self.bgView.layer.borderColor = [UIColor colorWithHexString:@"#F3BB6C"].CGColor;
//        [self.bgView setBackgroundColor:[UIColor colorWithHexString:@"#FFF7EB"]];
//    }else{
//        self.bgView.layer.borderColor = [UIColor colorWithHexString:@"#C8C8C8"].CGColor;
//        [self.bgView setBackgroundColor:[UIColor whiteColor]];
//    }
//    
//}
- (void)setModel:(TLRechargeGoodsModel *)model{
    if (model) {
        _model = model;
        
        self.lxLab.text = [NSString stringWithFormat:@" %@  ",model.hint1];
        
        self.oneLab.text = model.goodsName;
        
        self.twoLab.text = [NSString stringWithFormat:@"$%.2f",model.price.floatValue];
        
        self.threeLab.text = model.hint2;
        
        if (model.tl_isSelected) {
        
            self.bgView.layer.borderColor = [UIColor colorWithHexString:@"#F3BB6C"].CGColor;
            [self.bgView setBackgroundColor:[UIColor colorWithHexString:@"#FFF7EB"]];
        }else{
        
            self.bgView.layer.borderColor = [UIColor colorWithHexString:@"#C8C8C8"].CGColor;
            [self.bgView setBackgroundColor:[UIColor whiteColor]];
        }
        
        [self layoutIfNeeded];
        
        [_lxView addRoundingCornersWithRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomRight andCornerRadii:8];
        
    }
}
@end
